<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>列表的进入和离开过渡</title>
    <script src="vue.js"></script>

</head>
<body>
    <div id="app"> 
        <button @click="add">随机插入一个数字</button>
        <button @click="remove">随机移除一个数字</button>
        <transition-group name="list" tag="p">
            <span v-for="item in items":key="item" class="list-item">
                {{item}}
            </span>
        </transition-group>
    </div>
    <script>
        var vm=new Vue({
            el:'#app',
            data:{
                items:[1,2,3,4,5],
                nextNum:6
            },
            methods:{
                randomIndex(){
                    return Math.floor(Math.random()*this.items.length)
                },
                add(){
                    this.items.splice(this.randomIndex(),0,this.nextNum++)
                },
                remove(){
                    this.items.splice(this.randomIndex(),1)
                }
            }

        })
        
    </script>
</body>
</html>